<template>
  <div class="app-container">
<!--    隐藏域 记录id-->
    <input type="hidden" v-model="student.id"/>
    <el-form ref="form" :model="student" label-width="120px">
      <el-form-item label="姓名">
        <el-input v-model="student.sname" />
      </el-form-item>
      <!-- <el-form-item label="性别">
=======
      <el-form-item label="性别">
>>>>>>> origin/wangboDev
        <el-input v-model="student.sex" />
      </el-form-item>
      <el-form-item label="生日">
        <el-input v-model="student.birthday" />
<<<<<<< HEAD
      </el-form-item> -->


      <el-form-item label="性别：">
        <el-radio-group v-model="student.sex">
          <el-radio label="男" aria-checked="true"/>
          <el-radio label="女" />
        </el-radio-group>
      </el-form-item>
      <el-form-item label="生日：">
        <el-date-picker
            v-model="student.birthday"
            type="date"
            placeholder="请选择出生日期"
            style="width: 100%"
            value-format="yyyy-MM-dd"
        />
      </el-form-item>

      <el-form-item label="班级ID">
        <el-input v-model="student.classid" />
      </el-form-item>
      <el-form-item label="创建时间">
        <el-input v-model="student.ctime" disabled />
      </el-form-item>
      <el-form-item>
        <el-button type="primary"  @click="onSubmit">修改学生</el-button>
        <el-button @click="onCancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import request from '@/utils/request'
export default {
  data() {
    return {
      student: {
        id:0,
        sname: '',
        sex: '',
        birthday:'',
        classid:'',
        ctime:''
      }
    }
  },
  mounted() {
    this.student=this.$store.state.user.student;
  },
  methods: {
    onSubmit() {
      // 请求接口 实现用户新增接口的调用
      request({
        url:"/edu/student/update.do",
        method: "POST",
        data:this.student
      }).then(res=>{
        if(res.code==0){
          //跳转到列表页面
          this.$router.push("/studentlist");
        }
      })
    },
    onCancel() {
      this.$message({
        message: 'cancel!',
        type: 'warning'
      });
      this.$router.push("/studentlist");
    }
  }
}
</script>

<style scoped>
.line{
  text-align: center;
}
</style>

